package messaage;

public class LoggedInMsg extends Message {

    private boolean isUserModerator;

	public LoggedInMsg(String _username, boolean _isModerator) {
		this.username = _username;
                this.isUserModerator = _isModerator;
	}

        public LoggedInMsg(String msg){
        	//System.out.println("LoggedInMsg = "+msg);
            this.parse(msg);
        }

	@Override
	public String toString() {
		String msg = "Logged In\n" + "Username:" + this.username + "\n"+
				this.isUserModerator+ '\0';

		return msg;
	}

        public boolean isModerator(){
            return this.isUserModerator;
        }

    private void parse(String msg) {
        String[] splitted = msg.split("\n");
        this.username = splitted[1].split(":")[1];
        //System.out.println("username = "+this.username);
        this.isUserModerator = splitted[2].contains("true");
        //System.out.println("isUserModerator = "+this.isUserModerator);
    }




}
